package win.smartown.easyAdapter.demo;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import win.smartown.library.easyAdapter.ColorDivider;
import win.smartown.library.easyAdapter.EasyAdapter;
import win.smartown.library.easyAdapter.EasyViewHolder;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new ColorDivider(Color.parseColor("#cccccc"), 1));
        recyclerView.setAdapter(new EasyAdapter(this) {
            @Override
            public void onBindViewHolder(EasyViewHolder holder, int position) {
                holder.getTextView(R.id.text).setText("" + position);
            }

            @Override
            public int getItemLayout(int viewType) {
                return R.layout.item;
            }

            @Override
            public int getItemCount() {
                return 20;
            }
        });
    }
}
